package com.bite.demo.controller;

import com.bite.demo.config.UserInfo;
import com.bite.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

@Controller
public class UserController {

//    属性注入
    @Autowired
    private UserService us;
    //使用@Qualifier 指定bean
//    @Qualifier("userInfo2")
//    @Autowired
//    private UserInfo userInfo;

    //使用@Resource指定bean
    @Resource(name = "uu")
    private UserInfo userInfo;

    public UserController() {
    }

    //构造方法注入
//    private UserService us;
//    private UserInfo userInfo;

//    public UserController() {
//    }

//    @Autowired
//    public UserController(UserService us) {
//        this.us = us;
//    }

//    public UserController(UserService us, UserInfo userInfo) {
//        this.us = us;
//        this.userInfo = userInfo;
//    }

    //Setter方法注入
//    private UserService us;
//
//    @Autowired
//    public void setUs(UserService us) {
//        this.us = us;
//    }

    public void doController(){
        us.doService();
        System.out.println(userInfo);
        System.out.println("do Controller.....");
    }
}
